package com.qf.controller;

import com.qf.pojo.City;
import com.qf.pojo.ResponseData;
import com.qf.service.CityService;
import com.qf.utils.JsonUtils;
import com.qf.vo.VoCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/city")
public class CitySys {
    @Autowired
    private CityService cityService;
    @RequestMapping("/citys")
    @ResponseBody
    public ResponseData citys(Integer getid,Integer backid){
        VoCity vocitys = cityService.citys(getid, backid);
        if (vocitys==null){
            return JsonUtils.createJson(0,"无查询结果");
        }
        //封装vocity实体
            return JsonUtils.createJson(1,vocitys);
    }

    @RequestMapping("/select")
    @ResponseBody
    public ResponseData select(Integer pid){
        //调用业务层
        List<City> list = cityService.findCityById(pid);
        if (list==null){
            return JsonUtils.createJson(0,"显示错误");
        }
        return JsonUtils.createJson(1,list);
    }
}
